/**
 * @author code@e-xtrategy.net
 * download last release http://code.google.com/p/e-xloading/
 * @version 1.0.0
 */
var EX_JQUERY_LOADING_COUNTER = 0;
(function($){
 $.fn.startLoading = function(options) {  
	 var defaults = {  
			 opstart: 0,  
			 loadingClass: "Loading",    
			 zindex:2,  
			 velocity: 500,
			 opend: 0.9
	 };
	 var options = $.extend(defaults, options);
	 return this.each(function() {
		 if (EX_JQUERY_LOADING_COUNTER==0) { 
			 obj = $(this);
			 var element = "<div class='"+options.loadingClass+"'";
			 element = element + "style='opacity:"+options.opstart+";display:block;position:absolute;top:0;left:0;width:"+obj.innerWidth()+"px;height:"+obj.innerHeight()+"px;";
			 element = element + "z-index:"+options.zindex+";'></div>"; 
			 obj.prepend(element);
			 obj.children("."+options.loadingClass).fadeTo(options.velocity,options.opend);
		 }	 
		 EX_JQUERY_LOADING_COUNTER++;
	 });  
 };  
})(jQuery);

(function($){  
	 $.fn.stopLoading = function(options) {  
		 var defaults = {  
				 opstart: 0,
				 velocity: 500,
				 loadingClass: "Loading",
				 opend: 0.9
		 };
		 var options = $.extend(defaults, options);
		 return this.each(function() {
			 EX_JQUERY_LOADING_COUNTER--;
			 if (EX_JQUERY_LOADING_COUNTER==0) {
				 obj = $(this);
				 obj.children("."+options.loadingClass).fadeTo(options.velocity,options.opstart,function(){obj.children("."+options.loadingClass).remove();});
			 }	 
		 });  
	 };  
	})(jQuery);

